package com.tlgen.orm.components.serializer;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;

public class LongToStringSerializer extends JsonSerializer<Long> {

    @Override
    public void serialize(Long value, JsonGenerator gen, SerializerProvider provider)
            throws IOException {
        // 将所有 Long 值序列化为字符串
        if (value != null) {
            gen.writeString(value.toString());
        } else {
            gen.writeNull();
        }
    }

}